from pathlib import Path
import pandas as pd
from keras.models import Sequential
from keras_model_hub import TextCNNModel, RNNModel, CNNRNNModel,RNNAttentionModel, CNNRNNAttentionModel

FILE_DIR = '/Users/summy/project/python/parttime/归档/huigui'

def read_data(file_dir):
	dir = Path(file_dir)
	df1 = pd.read_excel(dir / 'data1.xlsx')
	df3 = pd.read_excel(dir / 'data3.xlsx')
	df = pd.concat([df1, df3], axis=0)

	df2 = pd.read_excel(dir / 'data2.xlsx')
	return df[['x1', 'x2']].values, df['y'].values, df2[['x1', 'x2']].values, df2['y'].values


if __name__ == '__main__':
	X_train, y_train, X_test, y_test = read_data(FILE_DIR)
	X_train = X_train.reshape(X_train.shape[0], X_train.shape[1], 1)
	X_test = X_test.reshape(X_test.shape[0], X_test.shape[1], 1)
	# model = RNNModel(1, activation=None)
	# model = TextCNNModel(1, activation=None)
	# model = CNNRNNModel(1, activation=None)
	# model = RNNAttentionModel(1, activation=None)
	model = CNNRNNAttentionModel(1, activation=None)

	model.compile(loss='mse', optimizer='adam', metrics=['mse'])
	model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=20)
